<p>The DSO support for loading individual Apache modules is based
on a module named <code class="module"><a href="./mod/mod_so.html">mod_so</a></code> which must be statically
compiled into the Apache core. It is the only module besides
<code class="module"><a href="./mod/core.html">core</a></code> which cannot be put into a DSO
itself. Practically all other distributed Apache modules can then
be placed into a DSO by individually enabling the DSO build for
them via <code class="program"><a href="./programs/configure.html">configure</a></code>'s
<code>--enable-<em>module</em>=shared</code> option as discussed
in the <a href="install.html">install documentation</a>. After a
module is compiled into a DSO named <code>mod_foo.so</code> you
can use <code class="module"><a href="./mod/mod_so.html">mod_so</a></code>'s <code class="directive"><a href="./mod/mod_so.html#loadmodule">LoadModule</a></code> command in your
<code>httpd.conf</code> file to load this module at server startup
or restart.</p>
<p>To simplify this creation of DSO files for Apache modules
(especially for third-party modules) a new support program
named <code class="program"><a href="./programs/apxs.html">apxs</a></code> (<dfn>APache
eXtenSion</dfn>) is available. It can be used to build DSO based
modules <em>outside of</em> the Apache source tree. The idea is
simple: When installing Apache the <code class="program"><a href="./programs/configure.html">configure</a></code>'s
<code>make install</code> procedure installs the Apache C
header files and puts the platform-dependent compiler and
linker flags for building DSO files into the <code class="program"><a href="./programs/apxs.html">apxs</a></code>
program. This way the user can use <code class="program"><a href="./programs/apxs.html">apxs</a></code> to compile
his Apache module sources without the Apache distribution
source tree and without having to fiddle with the
platform-dependent compiler and linker flags for DSO
<code>httpd.conf</code> configuration commands instead of
<code class="program"><a href="./programs/configure.html">configure</a></code> options at build-time. For instance
this way one is able to run different server instances
(standard & SSL version, minimalistic & powered up
version [mod_perl, PHP3], <em>etc.</em>) with only one Apache
installation.</li>
<li>The server package can be easily extended with
third-party modules even after installation. This is at least
a great benefit for vendor package maintainers who can create
a Apache core package and additional packages containing
extensions like PHP3, mod_perl, mod_fastcgi,
<em>etc.</em></li>
<li>Easier Apache module prototyping because with the
DSO/<code class="program"><a href="./programs/apxs.html">apxs</a></code> pair you can both work outside the
Apache source tree and only need an <code>apxs -i</code>
command followed by an <code>apachectl restart</code> to
bring a new version of your currently developed module into
the running Apache server.</li>
</ul>
<p>DSO has the following disadvantages:</p>
<ul>
<li>The DSO mechanism cannot be used on every platform
because not all operating systems support dynamic loading of
code into the address space of a program.</li>
<li>The server is approximately 20% slower at startup time
because of the symbol resolving overhead the Unix loader now
has to do.</li>
<li>The server is approximately 5% slower at execution time
under some platforms because position independent code (PIC)
sometimes needs complicated assembler tricks for relative
addressing which are not necessarily as fast as absolute
addressing.</li>
<li>Because DSO modules cannot be linked against other
DSO-based libraries (<code>ld -lfoo</code>) on all platforms
(for instance a.out-based platforms usually don't provide
this functionality while ELF-based platforms do) you cannot
use the DSO mechanism for all types of modules. Or in other
words, modules compiled as DSO files are restricted to only
use symbols from the Apache core, from the C library
(<code>libc</code>) and all other dynamic or static libraries
used by the Apache core, or from static library archives
(<code>libfoo.a</code>) containing position independent code.
The only chances to use other code is to either make sure the
Apache core itself already contains a reference to it or
loading the code yourself via <code>dlopen()</code>.</li>
</ul>
</div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="./en/dso.html" title="English"> en </a> |
<a href="./ja/dso.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
<a href="./ko/dso.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
</div><div id="footer">
<p class="apache">Copyright 1995-2006 The Apache Software Foundation or its licensors, as applicable.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>